// 模拟后端接口数据
import Mock from 'mockjs';
import {authorization, getUserInfo, login} from './response/user';
import {getFileList, getFolderList, getTableData, getUploadFileList} from "./response/data";

const Random = Mock.Random;

// 方式一
// Mock.mock('http://localhost:3000/user/doLogin', 'post', getUserInfo);
// 方式二
Mock.mock(/\/getUserInfo/, 'post', getUserInfo);
Mock.mock(/\/getTableData/, 'get', getTableData);
Mock.mock(/\/getFolderList/, 'get', getFolderList);
Mock.mock(/\/getFileList/, 'get', getFileList);
Mock.mock(/\/getUploadFileList/, 'get', getUploadFileList);

Mock.mock(/\/login/, 'post', login);
Mock.mock(/\/authorization/, 'get', authorization);

// 方式三
// Mock.mock(/\/getUserInfo/, {name: 'Jack'});

// 延迟请求
Mock.setup({timeout: 0});

Random.extend({
	fruit() {
		const fruits = ['apple', 'pear', 'lemon', 'peach'];
		return this.pick(fruits); // 从指定的数组中随机选取一个
	}
});

export default Mock;
